package DAO;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.ArrayList;

import table.ChooseCourse_View;
import util.BaseConnection;

public class ChooseCourse_View_DAO {
	public ArrayList<ChooseCourse_View> getList(String sno) {
		ArrayList<ChooseCourse_View> ar = new ArrayList<ChooseCourse_View>();
		Connection conn = BaseConnection.getConnection();
		PreparedStatement ps = null;
		ResultSet rs = null;
		String sql = "select * from ChooseCourse_View where Student_id = ?";
		try {
			ps = conn.prepareStatement(sql);
			ps.setString(1, sno);
			rs = ps.executeQuery();
			while (rs.next()) {
				ChooseCourse_View obj = new ChooseCourse_View();
				obj.setStudent_id(rs.getString(1));
				obj.setStudent_name(rs.getString(2));
				obj.setCourse_id(rs.getString(3));
				obj.setCourse_name(rs.getString(4));
				obj.setXB_name(rs.getString(5));
				obj.setCourse_type(rs.getString(6));
				obj.setCourse_credit(rs.getString(7));
				obj.setCourse_hours(rs.getString(8));
				obj.setTeacher_id(rs.getString(9));
				obj.setTeacher_name(rs.getString(10));
				ar.add(obj);
			}
		} catch (Exception e) {
			e.printStackTrace();
		}finally {
			BaseConnection.closeRes(rs, ps, conn);
		}
		
		return ar;
	}
	
	public static void main(String[] args) {
		System.out.println(new ChooseCourse_View_DAO().getList("201535020528").get(0).getStudent_name());
	}
}
